﻿Imports System.Runtime.Serialization

''' <summary>
''' A group of scripts
''' </summary>
''' <remarks></remarks>
''' <editHistory></editHistory>
<DataContract(Namespace:=Constants.DataContractNamespace)> _
Public Class ScriptGroup
    Inherits ItemBase

    Private _name As String
    Private _scripts As Scripts

    Public Sub New()
        _scripts = New Scripts
    End Sub

    ''' <summary>
    ''' Creates a new instance of the ScriptGroup class
    ''' </summary>
    ''' <param name="name">The name of the ScriptGroup</param>
    ''' <remarks></remarks>
    Public Sub New(ByVal name As String)
        Me.New()

        If String.IsNullOrEmpty(name) Then
            Throw New ArgumentException("No name was provided", "name")
        End If

        'Set the name of the script group
        _name = name
    End Sub


    ''' <summary>
    ''' Gets a value indicating whether the object is dirty.
    ''' </summary>
    ''' <value></value>
    ''' <remarks></remarks>
    Public Overrides ReadOnly Property IsDirty() As Boolean
        Get
            If MyBase.IsDirty Then
                Return True
            Else
                Return Me.Scripts.IsDirty
            End If
        End Get
    End Property

    ''' <summary>
    ''' Marks the object as clean
    ''' </summary>
    ''' <remarks></remarks>
    Friend Overrides Sub MarkClean()
        MyBase.MarkClean()

        Me.Scripts.MarkClean()
    End Sub

    ''' <summary>
    ''' Gets or sets the name of the script
    ''' </summary>
    ''' <value></value>
    ''' <remarks></remarks>
    <DataMember()> _
    Public Property Name() As String
        Get
            Return _name
        End Get
        Set(ByVal value As String)
            _name = value

            MarkDirty("Name")
        End Set
    End Property

    ''' <summary>
    ''' Gets the scripts for this group
    ''' </summary>
    ''' <value></value>
    ''' <remarks></remarks>
    <DataMember()> _
    Public Property Scripts() As Scripts
        Get
            Return _scripts
        End Get
        Private Set(ByVal value As Scripts)
            _scripts = value
        End Set
    End Property

End Class
